home *** CD-ROM | disk | FTP | other *** search
/ Amiga Games Extra 1996 June / Amiga Games Extra 1996 #6.iso / userbox / publicdomain / urouhack / source / urouhack.c < prev   
C/C++ Source or Header  |  1996-03-24  |  40KB  |  1,284 lines

  1. /********************************************************************************/
  2. /* Urouhack V1.4 by Tinic Urou 24.03.96                                         */
  3. /*                                                                              */
  4. /* Please leave me a mail, if you are using this code.                          */
  5. /* And, it would be nice, if you could send me a copy of your modified codes    */
  6. /* uuencoded via mail.                                                          */
  7. /*                                                                              */
  8. /* 5uro@informatik.uni-hamburg.de                                               */
  9. /********************************************************************************/
  10.  
  11. /********************************************************************************/
  12. /* Some macros for class creation handling                                      */
  13. /********************************************************************************/
  14.  
  15. #define BOOPSI_Class( initName, dispatchName, ClassID, SuperClass, SuperClassPtr, InstantStruct, Flags)\
  16. Class  *initName(void);\
  17. ULONG   dispatchName(Class *, Object *, Msg);\
  18. Class * initName(void)\
  19. {\
  20.     Class *cl;\
  21.     extern ULONG HookEntry();\
  22.     if(cl=MakeClass(ClassID,SuperClass,SuperClassPtr,sizeof(struct InstantStruct), Flags))\
  23.     {\
  24.     cl->cl_Dispatcher.h_Entry   = HookEntry;\
  25.     cl->cl_Dispatcher.h_SubEntry= dispatchName;\
  26.     }\
  27.     return(cl);\
  28. }\
  29. __geta4 ULONG dispatchName(Class *cl, Object *object,Msg msg)\
  30. {\
  31.     struct InstantStruct *data;\
  32.     data=(struct *InstantStruct)0;\
  33.     switch(msg->MethodID)\
  34.     {
  35.  
  36. #define BOOPSI_Method( MethodID)\
  37.     case MethodID:
  38.  
  39. #define BOOPSI_Method_End\
  40.     break;
  41.  
  42. #define BOOPSI_InitData\
  43.     data=INST_DATA(cl,object);
  44.  
  45. #define BOOPSI_Method_SuperDefault\
  46.     default : return(DoSuperMethodA(cl,object,msg));
  47.  
  48. #define BOOPSI_Method_SuperReturn\
  49.     return(DoSuperMethodA(cl,object,msg));
  50.  
  51. #define BOOPSI_End\
  52.     }\
  53. }
  54.  
  55. /********************************************************************************/
  56. /* Includes and libbases                                                        */
  57. /********************************************************************************/
  58.  
  59. #include <exec/types.h>
  60. #include <intuition/intuition.h>
  61. #include <intuition/classes.h>
  62. #include <intuition/classusr.h>
  63. #include <intuition/imageclass.h>
  64. #include <intuition/gadgetclass.h>
  65. #include <intuition/cghooks.h>
  66. #include <intuition/icclass.h>
  67. #include <utility/tagitem.h>
  68. #include <utility/hooks.h>
  69. #include <clib/intuition_protos.h>
  70. #include <clib/utility_protos.h>
  71. #include <clib/alib_protos.h>
  72. #include <clib/alib_stdio_protos.h>
  73. #include <intuition/IntuitionBase.h>
  74. #include <graphics/gfxbase.h>
  75. #include <graphics/text.h>
  76. #include <datatypes/datatypes.h>
  77. #include <datatypes/pictureclass.h>
  78. #include <dos/dos.h>
  79. #include <dos/rdargs.h>
  80. #include <exec/memory.h>
  81. #include <exec/tasks.h>
  82. #include <clib/macros.h>
  83.  
  84. extern       struct IntuitionBase *IntuitionBase;
  85. extern       struct Library       *UtilityBase;
  86. static const char                 *version="$VER: Urouhack V1.4 by Tinic Urou. This is GIFTWARE!";
  87.  
  88. ULONG       *swim_in_my_pool;
  89.  
  90. BOOL    pframes         = TRUE,
  91.     psysi           = TRUE,
  92.     sysihackstyle   = FALSE,
  93.     pwin            = TRUE,
  94.     trymwb          = FALSE,
  95.     XStyle          = FALSE;
  96.  
  97. /********************************************************************************/
  98. /* Append new pens to the DrawInfo and allocate them                            */
  99. /********************************************************************************/
  100.  
  101. #define HALFSHADOWPEN   (0x000C)
  102. #define HALFSHINEPEN    (0x000D)
  103. #define DARKPAINTPEN    (0x000E)    /* Brown  on MagicWB */
  104. #define SHINEPAINTPEN   (0x000F)    /* Orange on MagicWB */
  105.  
  106. #define NEWNUMDRIPENS   (0x0010)
  107. #define NEWDRIVERSION   (0x0003)
  108.  
  109. struct NewPenStruct
  110. {
  111.     UWORD halfdark;
  112.     UWORD halfshine;
  113.     UWORD darkpaint;
  114.     UWORD shinepaint;
  115. };
  116.  
  117. struct ExtNewPenStruct
  118. {
  119.     ULONG   c1r;
  120.     ULONG   c1g;
  121.     ULONG   c1b;
  122.     ULONG   c2r;
  123.     ULONG   c2g;
  124.     ULONG   c2b;
  125.     ULONG   c3r;
  126.     ULONG   c3g;
  127.     ULONG   c3b;
  128.     ULONG   c4r;
  129.     ULONG   c4g;
  130.     ULONG   c4b;
  131. };
  132.  
  133. /********************************************************************************/
  134. /* Default shit                                                                 */
  135. /********************************************************************************/
  136.  
  137. BYTE    b_top   = 3,
  138.     b_bottom= 3,
  139.     b_left  = 3,
  140.     b_right = 3,
  141.  
  142.     b_height=14,
  143.     b_width =18;
  144.  
  145. struct NewPenStruct p1={1,0,1,1};
  146. struct NewPenStruct p2={4,5,6,7};
  147.  
  148. struct NewPenStruct *penlist[256]=
  149. {
  150.     &p1,
  151.     &p2
  152. };
  153.  
  154. BOOL exttrymwb[256];
  155.  
  156. char *namelist[256]=
  157. {
  158.     "Free Britanny!",
  159.     "Workbench"
  160. };
  161.  
  162. /********************************************************************************/
  163. /* Patch area                                                                   */
  164. /********************************************************************************/
  165.  
  166. static ULONG AllocVecPooled(ULONG *pool, ULONG memsize)
  167. {
  168.     ULONG *memory;
  169.     memsize += ( sizeof(ULONG) + sizeof(ULONG) );
  170.     if(memory=(ULONG *)AllocPooled(pool,memsize))
  171.     {
  172.     memory[0]=pool;
  173.     memory[1]=memsize;
  174.     memory+=2L;        /* Why +=2L? Its a Pointer to ULONG, so DICE will convert this to 8.*/
  175.     }                      /* Didn´t know that and had serious problems with it 8))            */
  176.     return(memory);
  177. }
  178. static void  FreeVecPooled(ULONG *memory)
  179. {
  180.     FreePooled(memory[-2L],memory-2L,memory[-1L]);
  181. }
  182.  
  183. int GetPubScreens(struct Screen *src, char *namelist[])
  184. {
  185.     struct List     *PubScreenList;
  186.     struct PubScreenNode *ScreenNode;
  187.  
  188.     PubScreenList = LockPubScreenList();
  189.     for(ScreenNode=(struct PubScreenNode *)PubScreenList->lh_Head;ScreenNode->psn_Node.ln_Succ;ScreenNode=(struct PubScreenNode *)ScreenNode->psn_Node.ln_Succ)
  190.     {
  191.     if(ScreenNode->psn_Screen==src)
  192.     {
  193.         int i=0;
  194.  
  195.         while(namelist[i])
  196.         {
  197.         if(strcmp(ScreenNode->psn_Node.ln_Name,namelist[i])==0)
  198.         {
  199.             UnlockPubScreenList();
  200.             return(i);
  201.         }
  202.         i++;
  203.         }
  204.         UnlockPubScreenList();
  205.         return(0);
  206.     }
  207.     }
  208.     UnlockPubScreenList();
  209.     return(0);
  210. }
  211.  
  212. __geta4 void allocNewPens(__A2 struct Screen *scr)
  213. {
  214.     struct DrawInfo *dr;
  215.     int                     i;
  216.  
  217.     static struct ExtNewPenStruct defpens=
  218.     {
  219.     0x80808080,0x80808080,0x80808080,
  220.     0xafafafaf,0xafafafaf,0xafafafaf,
  221.     0xaaaaaaaa,0x99999999,0x77777777,
  222.     0xffffffff,0xa9a9a9a9,0x97979797
  223.     };
  224.  
  225.     if(dr=GetScreenDrawInfo(scr))
  226.     {
  227.     if(dr->dri_Version==DRI_VERSION)
  228.     {
  229.         UWORD   *newpens;
  230.         if(newpens=(UWORD *)AllocVecPooled(swim_in_my_pool, (NEWNUMDRIPENS+1) * sizeof(UWORD) + sizeof(ULONG) ))
  231.         {
  232.         ((ULONG *)newpens)[0] =dr->dri_Pens;
  233.         ((ULONG *)newpens)   +=1L;             /* Save old pens */
  234.  
  235.         CopyMem(dr->dri_Pens,newpens,NUMDRIPENS<<1);
  236.         dr->dri_Pens            = newpens;
  237.         dr->dri_Version         = NEWDRIVERSION;
  238.         newpens[NEWNUMDRIPENS]  = ~0;
  239.  
  240.         if(i=GetPubScreens(scr,namelist))
  241.         {
  242.             if(exttrymwb[i]) /* Try to allocate Mwb colors on selected screen */
  243.             {
  244.             i=ObtainBestPen(scr->ViewPort.ColorMap,defpens.c1r,defpens.c1g, defpens.c1b,OBP_Precision,PRECISION_IMAGE,TAG_DONE);
  245.             newpens[HALFSHADOWPEN]= i>-1 ? i : penlist[0]->halfdark;
  246.             i=ObtainBestPen(scr->ViewPort.ColorMap,defpens.c2r,defpens.c2g, defpens.c2b,OBP_Precision,PRECISION_IMAGE,TAG_DONE);
  247.             newpens[HALFSHINEPEN] = i>-1 ? i : penlist[0]->halfshine;
  248.             i=ObtainBestPen(scr->ViewPort.ColorMap,defpens.c3r,defpens.c3g, defpens.c3b,OBP_Precision,PRECISION_IMAGE,TAG_DONE);
  249.             newpens[DARKPAINTPEN] = i>-1 ? i : penlist[0]->darkpaint;
  250.             i=ObtainBestPen(scr->ViewPort.ColorMap,defpens.c4r,defpens.c4g, defpens.c4b,OBP_Precision,PRECISION_IMAGE,TAG_DONE);
  251.             newpens[SHINEPAINTPEN]= i>-1 ? i : penlist[0]->shinepaint;
  252.             }
  253.             else
  254.             {
  255.             newpens[HALFSHADOWPEN]=penlist[i]->halfdark;
  256.             newpens[HALFSHINEPEN]= penlist[i]->halfshine;
  257.             newpens[DARKPAINTPEN]= penlist[i]->darkpaint;
  258.             newpens[SHINEPAINTPEN]=penlist[i]->shinepaint;
  259.             }
  260.         }
  261.         else
  262.         {
  263.             if(trymwb) /* Try to allocate Mwb colors on any screen */
  264.             {
  265.             i=ObtainBestPen(scr->ViewPort.ColorMap,defpens.c1r,defpens.c1g, defpens.c1b,OBP_Precision,PRECISION_IMAGE,OBP_FailIfBad,TRUE,TAG_DONE);
  266.             newpens[HALFSHADOWPEN]= i>-1 ? i : penlist[0]->halfdark;
  267.             i=ObtainBestPen(scr->ViewPort.ColorMap,defpens.c2r,defpens.c2g, defpens.c2b,OBP_Precision,PRECISION_IMAGE,OBP_FailIfBad,TRUE,TAG_DONE);
  268.             newpens[HALFSHINEPEN] = i>-1 ? i : penlist[0]->halfshine;
  269.             i=ObtainBestPen(scr->ViewPort.ColorMap,defpens.c3r,defpens.c3g, defpens.c3b,OBP_Precision,PRECISION_IMAGE,OBP_FailIfBad,TRUE,TAG_DONE);
  270.             newpens[DARKPAINTPEN] = i>-1 ? i : penlist[0]->darkpaint;
  271.             i=ObtainBestPen(scr->ViewPort.ColorMap,defpens.c4r,defpens.c4g, defpens.c4b,OBP_Precision,PRECISION_IMAGE,OBP_FailIfBad,TRUE,TAG_DONE);
  272.             newpens[SHINEPAINTPEN]= i>-1 ? i : penlist[0]->shinepaint;
  273.             }
  274.             else /* No! */
  275.             {
  276.             newpens[HALFSHADOWPEN]= penlist[0]->halfdark;
  277.             newpens[HALFSHINEPEN] = penlist[0]->halfshine;
  278.             newpens[DARKPAINTPEN] = penlist[0]->darkpaint;
  279.             newpens[SHINEPAINTPEN]= penlist[0]->shinepaint;
  280.             }
  281.         }
  282.         }
  283.     }
  284.     FreeScreenDrawInfo(scr,dr);
  285.     }
  286. }
  287.  
  288. __geta4 freeNewPens(__A0 struct Screen *scr)
  289. {
  290.     struct DrawInfo *dr;
  291.     if(dr=GetScreenDrawInfo(scr))
  292.     {
  293.     if(dr->dri_Version==NEWDRIVERSION)
  294.     {
  295.         UWORD *newpens  = dr->dri_Pens;
  296.         dr->dri_Pens    = (UWORD *)((ULONG *)newpens)[-1L];
  297.         dr->dri_Version = DRI_VERSION;
  298.  
  299.         FreeVecPooled     (((ULONG *)newpens)-1L);
  300.         FreeScreenDrawInfo(scr,dr);
  301.     }
  302.     }
  303. }
  304.  
  305. /********************************************************************************/
  306. /* This change is needed for some programs like DeliTrackerII etc...            */
  307. /********************************************************************************/
  308.  
  309. __geta4 void changeSize(__A0 struct NewWindow *win,__A1 struct TagItem *tags)
  310. {
  311.     struct TagItem  *ti;
  312.     if(tags)
  313.     {
  314.     ULONG flags=GetTagData(WA_Flags,win ? win->Flags : 0 ,tags); /* Oh yeah, I forgot to check if win was TRUE in 1.3 8)) */
  315.     if(flags&WFLG_SIZEGADGET)
  316.     {
  317.         if(flags&WFLG_SIZEBBOTTOM)
  318.         {
  319.         if(ti=FindTagItem(WA_InnerHeight,tags))
  320.         {
  321.             ti->ti_Data+=(b_height-10);
  322.         }
  323.         }
  324.         if(flags&WFLG_SIZEBRIGHT)
  325.         {
  326.         if(ti=FindTagItem(WA_InnerWidth,tags))
  327.         {
  328.             ti->ti_Data+=(b_width-10);
  329.         }
  330.         }
  331.     }
  332.     }
  333. }
  334.  
  335. /********************************************************************************/
  336. /* standard function for drawing frames, I should convert this to assembler.... */
  337. /********************************************************************************/
  338.  
  339. void draw_frame(struct RastPort *rp, UWORD x, UWORD y, UWORD width, UWORD height, UWORD col1, UWORD col2, UWORD col3, UWORD col4, UWORD col5, BOOL bg)
  340. {
  341.     if((width>x)&&(height>y))
  342.     {
  343.     UWORD *ptr=rp->AreaPtrn; rp->AreaPtrn=0L;
  344.     SetAPen(rp,col1);
  345.     RectFill(rp,x,y,width,y);
  346.     RectFill(rp,x,y,x,height);
  347.     SetAPen(rp,col2);
  348.     RectFill(rp,width,y,width,height);
  349.     RectFill(rp,x,height,width,height);
  350.     x++;y++;height--;width--;
  351.     if(bg)
  352.     {
  353.         SetAPen(rp,col5);
  354.         RectFill(rp,x+1,y+1,width-1,height-1);
  355.     }
  356.     SetAPen(rp,col3);
  357.     RectFill(rp,x,y,width,y);
  358.     RectFill(rp,x,y,x,height);
  359.     SetAPen(rp,col4);
  360.     RectFill(rp,x,height,width,height);
  361.     RectFill(rp,width,y,width,height);
  362.     rp->AreaPtrn=ptr;
  363.     }
  364. }
  365.  
  366. void draw_simple(struct RastPort *rp,UWORD x, UWORD y, UWORD width, UWORD height, UWORD col1, UWORD col2)
  367. {
  368.     if((width>x)&&(height>y))
  369.     {
  370.     SetAPen(rp,col1);
  371.     RectFill(rp,x,y,width,y);
  372.     RectFill(rp,x,y,x,height);
  373.     SetAPen(rp,col2);
  374.     RectFill(rp,width,y,width,height);
  375.     RectFill(rp,x,height,width,height);
  376.     }
  377. }
  378.  
  379. /******************************************************************/
  380. /* FRAMEICLASS Hack                                               */
  381. /******************************************************************/
  382.  
  383. struct FRAMEData
  384. {
  385.     ULONG type;
  386.     ULONG edgesonly;
  387.     ULONG recessed;
  388.     ULONG data;
  389. };
  390.  
  391. BOOL DrawXEN(struct impDraw *imsg,struct FRAMEData *data, struct RastPort *rp, UWORD minx, UWORD miny, UWORD maxx, UWORD maxy, UWORD *pens)
  392. {
  393.     switch (data->type)
  394.     {
  395.     case    FRAME_DEFAULT:
  396.     case    FRAME_BUTTON:
  397.         if (imsg->imp_State==IDS_NORMAL)
  398.         {
  399.             if(data->edgesonly)
  400.             {
  401.             if(!data->recessed) draw_frame (rp,minx,miny,maxx,maxy,pens[SHINEPEN],pens[SHADOWPEN],pens[HALFSHINEPEN],pens[HALFSHADOWPEN],0,FALSE);
  402.             else                draw_frame (rp,minx,miny,maxx,maxy,pens[SHADOWPEN],pens[SHINEPEN],pens[HALFSHADOWPEN],pens[HALFSHINEPEN],0,FALSE);
  403.             }
  404.             else
  405.             {
  406.             if(!data->recessed) draw_frame (rp,minx,miny,maxx,maxy,pens[SHADOWPEN],pens[SHADOWPEN],pens[SHINEPEN],pens[HALFSHADOWPEN],pens[HALFSHINEPEN],TRUE);
  407.             else                draw_frame (rp,minx,miny,maxx,maxy,pens[SHADOWPEN],pens[SHADOWPEN],pens[HALFSHADOWPEN],pens[SHINEPEN],pens[BACKGROUNDPEN],TRUE);
  408.             }
  409.         }
  410.         else
  411.         {
  412.             if(data->edgesonly)     draw_frame (rp,minx,miny,maxx,maxy,pens[SHADOWPEN],pens[SHINEPEN],pens[HALFSHADOWPEN],pens[HALFSHINEPEN],0,FALSE);
  413.             else                    draw_frame (rp,minx,miny,maxx,maxy,pens[SHADOWPEN],pens[SHADOWPEN],pens[HALFSHADOWPEN],pens[SHINEPEN],pens[BACKGROUNDPEN],TRUE);
  414.         }
  415.         break;
  416.     case    FRAME_RIDGE:
  417.         if(data->edgesonly)
  418.         {
  419.             if(!data->recessed)     draw_frame (rp,minx,miny,maxx,maxy,pens[SHINEPEN],pens[SHADOWPEN],pens[SHADOWPEN],pens[SHINEPEN],0,FALSE);
  420.             else                    draw_frame (rp,minx,miny,maxx,maxy,pens[SHADOWPEN],pens[SHINEPEN],pens[SHINEPEN],pens[SHADOWPEN],0,FALSE);
  421.         }
  422.         else
  423.         {
  424.             if(!data->recessed)     draw_frame (rp,minx,miny,maxx,maxy,pens[SHINEPEN],pens[SHADOWPEN],pens[SHADOWPEN],pens[SHINEPEN],pens[BACKGROUNDPEN],TRUE);
  425.             else                    draw_frame (rp,minx,miny,maxx,maxy,pens[SHADOWPEN],pens[SHINEPEN],pens[SHINEPEN],pens[SHADOWPEN],pens[BACKGROUNDPEN],TRUE);
  426.         }
  427.         break;
  428.     }
  429.     return(TRUE);
  430. }
  431.  
  432. BOOL DrawX(struct impDraw *imsg,struct FRAMEData *data, struct RastPort *rp, UWORD minx, UWORD miny, UWORD maxx, UWORD maxy, UWORD *pens)
  433. {
  434.     switch (data->type)
  435.     {
  436.     case    FRAME_DEFAULT:
  437.     case    FRAME_BUTTON:
  438.         if (imsg->imp_State==IDS_NORMAL)
  439.         {
  440.             if(data->edgesonly)
  441.             {
  442.             if(!data->recessed) draw_frame (rp,minx,miny,maxx,maxy,pens[SHINEPEN],pens[HALFSHADOWPEN],pens[SHINEPEN],pens[HALFSHADOWPEN],0,FALSE);
  443.             else                draw_frame (rp,minx,miny,maxx,maxy,pens[HALFSHADOWPEN],pens[SHINEPEN],pens[HALFSHADOWPEN],pens[SHINEPEN],0,FALSE);
  444.             }
  445.             else
  446.             {
  447.             if(!data->recessed) draw_frame (rp,minx,miny,maxx,maxy,pens[SHINEPEN],pens[HALFSHADOWPEN],pens[SHINEPEN],pens[HALFSHADOWPEN],pens[HALFSHINEPEN],TRUE);
  448.             else                draw_frame (rp,minx,miny,maxx,maxy,pens[HALFSHADOWPEN],pens[SHINEPEN],pens[HALFSHADOWPEN],pens[SHINEPEN],pens[BACKGROUNDPEN],TRUE);
  449.             }
  450.         }
  451.         else
  452.         {
  453.             if(data->edgesonly)     draw_frame (rp,minx,miny,maxx,maxy,pens[HALFSHADOWPEN],pens[SHINEPEN],pens[HALFSHADOWPEN],pens[SHINEPEN],0,FALSE);
  454.             else                    draw_frame (rp,minx,miny,maxx,maxy,pens[HALFSHADOWPEN],pens[SHINEPEN],pens[HALFSHADOWPEN],pens[SHINEPEN],pens[BACKGROUNDPEN],TRUE);
  455.         }
  456.         break;
  457.     case    FRAME_RIDGE:
  458.         if(data->edgesonly)
  459.         {
  460.             if(!data->recessed)     draw_frame (rp,minx,miny,maxx,maxy,pens[SHINEPEN],pens[HALFSHADOWPEN],pens[HALFSHADOWPEN],pens[SHINEPEN],0,FALSE);
  461.             else                    draw_frame (rp,minx,miny,maxx,maxy,pens[HALFSHADOWPEN],pens[SHINEPEN],pens[SHINEPEN],pens[HALFSHADOWPEN],0,FALSE);
  462.         }
  463.         else
  464.         {
  465.             if(!data->recessed)     draw_frame (rp,minx,miny,maxx,maxy,pens[SHINEPEN],pens[HALFSHADOWPEN],pens[HALFSHADOWPEN],pens[SHINEPEN],pens[BACKGROUNDPEN],TRUE);
  466.             else                    draw_frame (rp,minx,miny,maxx,maxy,pens[HALFSHADOWPEN],pens[SHINEPEN],pens[SHINEPEN],pens[HALFSHADOWPEN],pens[BACKGROUNDPEN],TRUE);
  467.         }
  468.         break;
  469.     }
  470.     return(TRUE);
  471. }
  472.  
  473.  
  474. BOOPSI_Class(initFRAMEClass,dispatchFRAME,"frameiclass","breizhclass",NULL,FRAMEData, 0)
  475.  
  476.     BOOPSI_Method(OM_NEW)
  477.     {
  478.     ULONG   type,edgesonly,recessed;
  479.     type      =GetTagData(IA_FrameType,0L,((struct opSet *)msg)->ops_AttrList);
  480.     edgesonly =GetTagData(IA_EdgesOnly,0L,((struct opSet *)msg)->ops_AttrList);
  481.     recessed  =GetTagData(IA_Recessed ,0L,((struct opSet *)msg)->ops_AttrList);
  482.     if(object=(Object *)DoSuperMethodA(cl,object,msg))
  483.     {
  484.         BOOPSI_InitData
  485.         data->type      =type;
  486.         data->edgesonly =edgesonly;
  487.         data->recessed  =recessed;
  488.     }
  489.     return(object);
  490.     }
  491.     BOOPSI_Method_End
  492.  
  493.     BOOPSI_Method(IM_DRAWFRAME)
  494.     BOOPSI_Method(IM_DRAW)
  495.     {
  496.     BOOPSI_InitData
  497.  
  498.     if((data->type==FRAME_BUTTON)||(data->type==FRAME_RIDGE))
  499.     {
  500.         struct  impDraw     *imsg;
  501.         imsg=(struct impDraw *)msg;
  502.         if(imsg->imp_DrInfo)
  503.         {
  504.         UWORD   *pens;
  505.         pens=imsg->imp_DrInfo->dri_Pens;
  506.         if(imsg->imp_DrInfo->dri_Version==NEWDRIVERSION)
  507.         {
  508.             UWORD   minx,miny,maxx,maxy;
  509.             struct  RastPort    *rp;
  510.             rp  =imsg->imp_RPort;
  511.             minx=imsg->imp_Offset.X+((struct Image *)object)->LeftEdge;
  512.             miny=imsg->imp_Offset.Y+((struct Image *)object)->TopEdge;
  513.             maxx=minx+((msg->MethodID==IM_DRAWFRAME) ? imsg->imp_Dimensions.Width  : ((struct Image *)object)->Width )-1;
  514.             maxy=miny+((msg->MethodID==IM_DRAWFRAME) ? imsg->imp_Dimensions.Height : ((struct Image *)object)->Height)-1;
  515.             if(XStyle)
  516.             {
  517.             return(DrawX(imsg,data,rp,minx,miny,maxx,maxy,pens));
  518.             }
  519.             else
  520.             {
  521.             return(DrawXEN(imsg,data,rp,minx,miny,maxx,maxy,pens));
  522.             }
  523.         }
  524.         }
  525.     }
  526.     BOOPSI_Method_SuperReturn
  527.     }
  528.     BOOPSI_Method_End
  529.  
  530.     BOOPSI_Method_SuperDefault
  531.  
  532. BOOPSI_End
  533.  
  534. /********************************************************************/
  535. /* GADCLASS Hack                                                    */
  536. /*                                                                  */
  537. /* This patch is needed to adjust the position of the sizing gadget */
  538. /********************************************************************/
  539.  
  540. struct GADData
  541. {
  542.     ULONG what;
  543. };
  544.  
  545. BOOPSI_Class(initGADClass, dispatchGADClass, "buttongclass","tinicclass",NULL,GADData, 0)
  546.  
  547.     BOOPSI_Method(OM_NEW)
  548.     {
  549.     ULONG type=GetTagData(GA_SysGType,0L,((struct opSet *)msg)->ops_AttrList);
  550.  
  551.     if(object=(Object *)DoSuperMethodA(cl,object,msg))
  552.     {
  553.         if(type==GTYP_SIZING)
  554.         {
  555.         SetAttrs(object,GA_RelBottom,1-((struct Gadget *)(object))->Height,
  556.                 GA_RelRight, 1-((struct Gadget *)(object))->Width,
  557.                 TAG_DONE);
  558.         }
  559.     }
  560.     return(object);
  561.     }
  562.     BOOPSI_Method_End
  563.  
  564.     BOOPSI_Method_SuperDefault
  565.  
  566. BOOPSI_End
  567.  
  568. /******************************************************************/
  569. /* SYSIClass Hack                                                 */
  570. /******************************************************************/
  571.  
  572. struct SYSIData
  573. {
  574.     UWORD what;
  575.     UWORD dummy;
  576. };
  577.  
  578. ULONG DrawUrou(struct SYSIData *data,struct impDraw *imsg,Object *object, Class *cl, Msg msg)
  579. {
  580.     UWORD   y_size,dummy,minx,miny,maxx,maxy;
  581.     struct  RastPort    *rp;
  582.     UWORD   *pens;
  583.     pens=imsg->imp_DrInfo->dri_Pens;
  584.     rp=imsg->imp_RPort;
  585.     y_size=((struct Image *)object)->Height-1;
  586.     dummy=(y_size+1)>>1;
  587.     minx=imsg->imp_Offset.X+((struct Image *)object)->LeftEdge;
  588.     miny=imsg->imp_Offset.Y+((struct Image *)object)->TopEdge;
  589.     maxx=minx+((struct Image *)object)->Width-1;
  590.     maxy=miny+((struct Image *)object)->Height-1;
  591.  
  592.     switch (data->what)
  593.     {
  594.     case    SDEPTHIMAGE:
  595.         SetAPen(rp,pens[BACKGROUNDPEN]);
  596.         RectFill(rp,minx+1,miny+1,maxx-1,maxy-1);
  597.     case    ZOOMIMAGE:
  598.     case    DEPTHIMAGE:
  599.         minx++;
  600.     case    LEFTIMAGE:
  601.     case    UPIMAGE:
  602.     case    DOWNIMAGE:
  603.     case    RIGHTIMAGE:
  604.     case    SIZEIMAGE:
  605.     case    CLOSEIMAGE:
  606.         if(XStyle)
  607.         {
  608.             if(imsg->imp_State==IDS_SELECTED) draw_frame (rp,minx,miny,maxx,maxy,pens[HALFSHADOWPEN],pens[SHINEPEN],pens[HALFSHADOWPEN],pens[SHINEPEN],pens[HALFSHINEPEN],TRUE);
  609.             else                              draw_frame (rp,minx,miny,maxx,maxy,pens[SHINEPEN],pens[HALFSHADOWPEN],pens[SHINEPEN],pens[HALFSHADOWPEN],pens[HALFSHINEPEN],TRUE);
  610.         }
  611.         else
  612.         {
  613.             if(imsg->imp_State==IDS_SELECTED) draw_frame (rp,minx,miny,maxx,maxy,pens[SHADOWPEN],pens[SHINEPEN],pens[HALFSHADOWPEN],pens[HALFSHINEPEN],pens[BACKGROUNDPEN],TRUE);
  614.             else                              draw_frame (rp,minx,miny,maxx,maxy,pens[SHINEPEN],pens[SHADOWPEN],pens[HALFSHINEPEN],pens[HALFSHADOWPEN],pens[BACKGROUNDPEN],TRUE);
  615.         }
  616.         break;
  617.     };
  618.     switch (data->what)
  619.     {
  620.     case    LEFTIMAGE:
  621.         SetAPen(rp,pens[SHADOWPEN]);
  622.         Move(rp,minx+3,miny+dummy);
  623.         Draw(rp,maxx-3,maxy-3);
  624.         Draw(rp,maxx-3,miny+3);
  625.         SetAPen(rp,pens[SHINEPEN]);
  626.         Draw(rp,minx+3,maxy-dummy);
  627.         return(0L);
  628.     case    RIGHTIMAGE:
  629.         SetAPen(rp,pens[SHINEPEN]);
  630.         Move(rp,maxx-3,maxy-dummy);
  631.         Draw(rp,minx+3,miny+3);
  632.         Draw(rp,minx+3,maxy-3);
  633.         SetAPen(rp,pens[SHADOWPEN]);
  634.         Draw(rp,maxx-3,miny+dummy);
  635.         return(0L);
  636.     case    UPIMAGE:
  637.         SetAPen(rp,pens[SHADOWPEN]);
  638.         Move(rp,maxx-((maxx-minx)>>1),miny+3);
  639.         Draw(rp,maxx-3,maxy-3);
  640.         Draw(rp,minx+3,maxy-3);
  641.         SetAPen(rp,pens[SHINEPEN]);
  642.         Draw(rp,minx+((maxx-minx)>>1),miny+3);
  643.         return(0L);
  644.     case    DOWNIMAGE:
  645.         SetAPen(rp,pens[SHADOWPEN]);
  646.         Move(rp,maxx-((maxx-minx)>>1),maxy-3);
  647.         Draw(rp,maxx-3,miny+3);
  648.         SetAPen(rp,pens[SHINEPEN]);
  649.         Draw(rp,minx+3,miny+3);
  650.         Draw(rp,minx+((maxx-minx)>>1),maxy-3);
  651.         return(0L);
  652.         break;
  653.     case    SIZEIMAGE:
  654.         switch (imsg->imp_State)
  655.         {
  656.             case    IDS_NORMAL:
  657.             case    IDS_SELECTED:
  658.                 SetAPen(rp,pens[FILLPEN]);
  659.                 RectFill(rp,minx+1,miny+1,minx+((maxx-minx)>>1)-1,miny+dummy-1);
  660.                 break;
  661.         }
  662.         SetAPen(rp,pens[SHADOWPEN]);
  663.         RectFill(rp,minx+1,miny+dummy,minx+((maxx-minx)>>1),miny+dummy);
  664.         RectFill(rp,minx+((maxx-minx)>>1),miny+1,minx+((maxx-minx)>>1),miny+dummy);
  665.         SetAPen(rp,pens[SHINEPEN]);
  666.         RectFill(rp,minx+1,miny+dummy+1,minx+((maxx-minx)>>1)+1,miny+dummy+1);
  667.         RectFill(rp,minx+((maxx-minx)>>1)+1,miny+1,minx+((maxx-minx)>>1)+1,miny+dummy+1);
  668.         return(0L);
  669.     case    CLOSEIMAGE:
  670.         SetAPen(rp,pens[SHINEPEN]);
  671.         RectFill(rp,maxx+1,miny+1,maxx+1,maxy);
  672.         switch (imsg->imp_State)
  673.         {
  674.             case    IDS_NORMAL:
  675.                 SetAPen(rp,pens[SHINEPEN]);
  676.                 RectFill(rp,minx+4,miny+dummy-2,maxx-4,miny+dummy-2);
  677.                 RectFill(rp,minx+4,miny+dummy-2,minx+4,miny+dummy+1);
  678.                 SetAPen(rp,pens[SHADOWPEN]);
  679.                 RectFill(rp,minx+4,miny+dummy+1,maxx-4,miny+dummy+1);
  680.                 RectFill(rp,maxx-4,miny+dummy-2,maxx-4,miny+dummy+1);
  681.                 SetAPen(rp,pens[FILLPEN]);
  682.                 RectFill(rp,minx+5,miny+dummy-1,maxx-5,miny+dummy);
  683.                 break;
  684.             case    IDS_SELECTED:
  685.                 RectFill(rp,minx+6,miny+dummy-2,maxx-6,miny+dummy-2);
  686.                 RectFill(rp,minx+6,miny+dummy-2,minx+6,miny+dummy+1);
  687.                 SetAPen(rp,pens[SHADOWPEN]);
  688.                 RectFill(rp,minx+6,miny+dummy+1,maxx-6,miny+dummy+1);
  689.                 RectFill(rp,maxx-6,miny+dummy-2,maxx-6,miny+dummy+1);
  690.                 SetAPen(rp,pens[FILLPEN]);
  691.                 RectFill(rp,minx+7,miny+dummy-1,maxx-7,miny+dummy);
  692.                 break;
  693.             default:
  694.                 SetAPen(rp,pens[SHINEPEN]);
  695.                 RectFill(rp,minx+4,miny+dummy-2,maxx-4,miny+dummy-2);
  696.                 RectFill(rp,minx+4,miny+dummy-2,minx+4,miny+dummy+1);
  697.                 SetAPen(rp,pens[SHADOWPEN]);
  698.                 RectFill(rp,minx+4,miny+dummy+1,maxx-4,miny+dummy+1);
  699.                 RectFill(rp,maxx-4,miny+dummy-2,maxx-4,miny+dummy+1);
  700.                 break;
  701.         }
  702.         return(0L);
  703.     case    DEPTHIMAGE:
  704.     case    SDEPTHIMAGE:
  705.         minx--;
  706.         SetAPen(rp,pens[SHADOWPEN]);
  707.         RectFill(rp,minx,miny+1,minx,maxy);
  708.         switch (imsg->imp_State)
  709.         {
  710.             case    IDS_NORMAL:
  711.                 draw_simple(rp,minx+((maxx-minx)>>1)-1,miny+5,maxx-3,maxy-3,pens[SHINEPEN],pens[SHADOWPEN]);
  712.                 draw_simple(rp,minx+4,miny+3,minx+((maxx-minx)>>1)+3,maxy-5,pens[SHINEPEN],pens[SHADOWPEN]);
  713.                 SetAPen(rp,pens[FILLPEN]);
  714.                 RectFill(rp,minx+5,miny+4,minx+((maxx-minx)>>1)+2,maxy-6);
  715.                 break;
  716.             case    IDS_SELECTED:
  717.                 draw_simple(rp,minx+4,miny+3,minx+((maxx-minx)>>1)+3,maxy-5,pens[SHINEPEN],pens[SHADOWPEN]);
  718.                 draw_simple(rp,minx+((maxx-minx)>>1)-1,miny+5,maxx-3,maxy-3,pens[SHINEPEN],pens[SHADOWPEN]);
  719.                 SetAPen(rp,pens[FILLPEN]);
  720.                 RectFill(rp,minx+((maxx-minx)>>1),miny+6,maxx-4,maxy-4);
  721.                 break;
  722.             default:
  723.                 draw_simple(rp,minx+((maxx-minx)>>1)-1,miny+5,maxx-3,maxy-3,pens[SHINEPEN],pens[SHADOWPEN]);
  724.                 draw_simple(rp,minx+4,miny+3,minx+((maxx-minx)>>1)+3,maxy-5,pens[SHINEPEN],pens[SHADOWPEN]);
  725.                 SetAPen(rp,pens[BACKGROUNDPEN]);
  726.                 RectFill(rp,minx+5,miny+4,minx+((maxx-minx)>>1)+2,maxy-6);
  727.                 break;
  728.         }
  729.         return(0L);
  730.     case    ZOOMIMAGE:
  731.         minx--;
  732.         SetAPen(rp,pens[SHADOWPEN]);
  733.         RectFill(rp,minx,miny+1,minx,maxy);
  734.         draw_simple(rp,minx+((maxx-minx)>>1)-1,miny+dummy-1,maxx-((maxx-minx)>>1)+2,miny+dummy,pens[SHADOWPEN],pens[SHINEPEN]);
  735.         return(0L);
  736.     default:
  737.         BOOPSI_Method_SuperReturn
  738.     }
  739. }
  740.  
  741. ULONG DrawSysiHack(struct SYSIData *data,struct impDraw *imsg,Object *object, Class *cl, Msg msg)
  742. {
  743.     UWORD   y_size,dummy,minx,miny,maxx,maxy,h,w;
  744.     struct  RastPort    *rp;
  745.     UWORD   *pens;
  746.     pens=imsg->imp_DrInfo->dri_Pens;
  747.     rp=imsg->imp_RPort;
  748.     y_size=((struct Image *)object)->Height-1;
  749.     dummy=(y_size+1)>>1;
  750.     minx=imsg->imp_Offset.X+((struct Image *)object)->LeftEdge;
  751.     miny=imsg->imp_Offset.Y+((struct Image *)object)->TopEdge;
  752.     w=((struct Image *)object)->Width;
  753.     h=((struct Image *)object)->Height;
  754.     maxx=minx+w-1;
  755.     maxy=miny+h-1;
  756.  
  757.     switch (data->what)
  758.     {
  759.     case    ZOOMIMAGE:
  760.     case    DEPTHIMAGE:
  761.         minx++;
  762.     case    LEFTIMAGE:
  763.     case    UPIMAGE:
  764.     case    DOWNIMAGE:
  765.     case    RIGHTIMAGE:
  766.     case    SIZEIMAGE:
  767.     case    CLOSEIMAGE:
  768.         switch(imsg->imp_State)
  769.         {
  770.             case    IDS_SELECTED:
  771.                 SetAPen(rp,pens[FILLPEN]);
  772.                 RectFill(rp,minx+1,miny+1,maxx-1,maxy-1);
  773.                 draw_simple(rp,minx,miny,maxx,maxy,pens[SHADOWPEN],pens[SHINEPEN]);
  774.                 break;
  775.             case    IDS_NORMAL:
  776.                 SetAPen(rp,pens[FILLPEN]);
  777.                 RectFill(rp,minx+1,miny+1,maxx-1,maxy-1);
  778.                 draw_simple(rp,minx,miny,maxx,maxy,pens[SHINEPEN],pens[SHADOWPEN]);
  779.                 break;
  780.             default:
  781.                 SetAPen(rp,pens[BACKGROUNDPEN]);
  782.                 RectFill(rp,minx+1,miny+1,maxx-1,maxy-1);
  783.                 draw_simple(rp,minx,miny,maxx,maxy,pens[SHINEPEN],pens[SHADOWPEN]);
  784.                 break;
  785.         }
  786.         break;
  787.     case    SDEPTHIMAGE:
  788.         SetAPen(rp,pens[BACKGROUNDPEN]);
  789.         RectFill(rp,minx+1,miny+1,maxx-1,maxy-1);
  790.         if(imsg->imp_State==IDS_SELECTED) draw_simple(rp,minx+1,miny,maxx,maxy,pens[SHADOWPEN],pens[SHINEPEN]);
  791.         else                              draw_simple(rp,minx+1,miny,maxx,maxy,pens[SHINEPEN],pens[SHADOWPEN]);
  792.         break;
  793.     };
  794.     switch (data->what)
  795.     {
  796.     case    LEFTIMAGE:
  797.         SetAPen(rp,pens[SHADOWPEN]);
  798.         Move(rp,minx+3,miny+dummy);
  799.         Draw(rp,maxx-3,maxy-3);
  800.         Draw(rp,maxx-3,miny+3);
  801.         SetAPen(rp,pens[SHINEPEN]);
  802.         Draw(rp,minx+3,maxy-dummy);
  803.         return(0L);
  804.     case    RIGHTIMAGE:
  805.         SetAPen(rp,pens[SHINEPEN]);
  806.         Move(rp,maxx-3,maxy-dummy);
  807.         Draw(rp,minx+3,miny+3);
  808.         Draw(rp,minx+3,maxy-3);
  809.         SetAPen(rp,pens[SHADOWPEN]);
  810.         Draw(rp,maxx-3,miny+dummy);
  811.         return(0L);
  812.     case    UPIMAGE:
  813.         SetAPen(rp,pens[SHADOWPEN]);
  814.         Move(rp,maxx-((maxx-minx)>>1),miny+3);
  815.         Draw(rp,maxx-3,maxy-3);
  816.         Draw(rp,minx+3,maxy-3);
  817.         SetAPen(rp,pens[SHINEPEN]);
  818.         Draw(rp,minx+((maxx-minx)>>1),miny+3);
  819.         return(0L);
  820.     case    DOWNIMAGE:
  821.         SetAPen(rp,pens[SHADOWPEN]);
  822.         Move(rp,maxx-((maxx-minx)>>1),maxy-3);
  823.         Draw(rp,maxx-3,miny+3);
  824.         SetAPen(rp,pens[SHINEPEN]);
  825.         Draw(rp,minx+3,miny+3);
  826.         Draw(rp,minx+((maxx-minx)>>1),maxy-3);
  827.         return(0L);
  828.         break;
  829.     case    ZOOMIMAGE:
  830.         minx--;
  831.         SetAPen(rp,pens[SHADOWPEN]);
  832.         RectFill(rp,minx,miny+1,minx,maxy);
  833.         if(imsg->imp_State==IDS_SELECTED)
  834.         {
  835.             draw_simple(rp,minx+4,miny+3,maxx-4,maxy-3,pens[SHINEPEN],pens[SHADOWPEN]);
  836.             draw_simple(rp,minx+5,miny+4,maxx-((w-4)>>1),maxy-((h-4)>>1)-1,pens[SHADOWPEN],pens[SHINEPEN]);
  837.         }
  838.         else
  839.         {
  840.             draw_simple(rp,minx+4,miny+3,maxx-4,maxy-3,pens[SHADOWPEN],pens[SHINEPEN]);
  841.             draw_simple(rp,minx+5,miny+4,maxx-((w-4)>>1),maxy-((h-4)>>1)-1,pens[SHINEPEN],pens[SHADOWPEN]);
  842.         }
  843.         return(0L);
  844.     case    CLOSEIMAGE:
  845.         {
  846.             UWORD foo,fao;
  847.             SetAPen(rp,pens[SHINEPEN]);
  848.             RectFill(rp,maxx+1,miny+1,maxx+1,maxy);
  849.             foo=(h-1)/3;
  850.             fao=(w-1)/3;
  851.             if(imsg->imp_State==IDS_SELECTED)
  852.             {
  853.  
  854.             draw_simple(rp,minx+fao+1,miny+foo+1,maxx-fao-1,maxy-foo-1,pens[SHADOWPEN],pens[SHINEPEN]);
  855.             }
  856.             else
  857.             {
  858.             draw_simple(rp,minx+fao,miny+foo,maxx-fao,maxy-foo,pens[SHADOWPEN],pens[SHINEPEN]);
  859.             }
  860.         }
  861.         return(0L);
  862.     case    DEPTHIMAGE:
  863.         minx--;
  864.         SetAPen(rp,pens[SHADOWPEN]);
  865.         RectFill(rp,minx,miny+1,minx,maxy);
  866.         switch (imsg->imp_State)
  867.         {
  868.             case    IDS_NORMAL:
  869.                 draw_simple(rp,minx+((maxx-minx)>>1)-1,miny+5,maxx-3,maxy-2,pens[SHINEPEN],pens[SHADOWPEN]);
  870.                 draw_simple(rp,minx+4,miny+3,minx+((maxx-minx)>>1)+3,maxy-4,pens[SHADOWPEN],pens[SHINEPEN]);
  871.                 SetAPen(rp,pens[FILLPEN]);
  872.                 RectFill(rp,minx+((maxx-minx)>>1),miny+6,maxx-4,maxy-3);
  873.                 break;
  874.             case    IDS_SELECTED:
  875.                 draw_simple(rp,minx+4,miny+3,minx+((maxx-minx)>>1)+3,maxy-4,pens[SHINEPEN],pens[SHADOWPEN]);
  876.                 draw_simple(rp,minx+((maxx-minx)>>1)-1,miny+5,maxx-3,maxy-2,pens[SHINEPEN],pens[SHADOWPEN]);
  877.                 break;
  878.             default:
  879.                 draw_simple(rp,minx+((maxx-minx)>>1)-1,miny+5,maxx-3,maxy-2,pens[SHINEPEN],pens[SHADOWPEN]);
  880.                 draw_simple(rp,minx+4,miny+3,minx+((maxx-minx)>>1)+3,maxy-4,pens[SHADOWPEN],pens[SHINEPEN]);
  881.                 SetAPen(rp,pens[BACKGROUNDPEN]);
  882.                 RectFill(rp,minx+((maxx-minx)>>1),miny+6,maxx-4,maxy-3);
  883.                 break;
  884.         }
  885.         return(0L);
  886.     case    SDEPTHIMAGE:
  887.         SetAPen(rp,pens[SHADOWPEN]);
  888.         RectFill(rp,minx,miny+1,minx,maxy);
  889.         switch (imsg->imp_State)
  890.         {
  891.             case    IDS_NORMAL:
  892.                 draw_simple(rp,minx+((maxx-minx)>>1)-1,miny+5,maxx-3,maxy-2,pens[SHINEPEN],pens[SHADOWPEN]);
  893.                 draw_simple(rp,minx+4,miny+3,minx+((maxx-minx)>>1)+3,maxy-4,pens[SHADOWPEN],pens[SHINEPEN]);
  894.                 SetAPen(rp,pens[BACKGROUNDPEN]);
  895.                 RectFill(rp,minx+((maxx-minx)>>1),miny+6,maxx-4,maxy-3);
  896.                 break;
  897.             case    IDS_SELECTED:
  898.                 draw_simple(rp,minx+4,miny+3,minx+((maxx-minx)>>1)+3,maxy-4,pens[SHINEPEN],pens[SHADOWPEN]);
  899.                 draw_simple(rp,minx+((maxx-minx)>>1)-1,miny+5,maxx-3,maxy-2,pens[SHINEPEN],pens[SHADOWPEN]);
  900.                 break;
  901.             default:
  902.                 draw_simple(rp,minx+((maxx-minx)>>1)-1,miny+5,maxx-3,maxy-2,pens[SHINEPEN],pens[SHADOWPEN]);
  903.                 draw_simple(rp,minx+4,miny+3,minx+((maxx-minx)>>1)+3,maxy-4,pens[SHADOWPEN],pens[SHINEPEN]);
  904.                 SetAPen(rp,pens[BACKGROUNDPEN]);
  905.                 RectFill(rp,minx+((maxx-minx)>>1),miny+6,maxx-4,maxy-3);
  906.                 break;
  907.         }
  908.         return(0L);
  909.     case    SIZEIMAGE:
  910.         minx--;
  911.         SetAPen(rp,pens[SHADOWPEN]);
  912.         Move(rp,maxx-3,miny+3);
  913.         Draw(rp,maxx-3,maxy-3);
  914.         Draw(rp,minx+3,maxy-3);
  915.         SetAPen(rp,pens[SHINEPEN]);
  916.         Draw(rp,maxx-3,miny+3);
  917.         return(0L);
  918.     default:
  919.         BOOPSI_Method_SuperReturn
  920.     }
  921. }
  922.  
  923. BOOPSI_Class(initSYSIClass,dispatchSYSIClass,"sysiclass","urouclass",NULL,SYSIData, 0)
  924.  
  925.     BOOPSI_Method(OM_NEW)
  926.     {
  927.     ULONG               what;
  928.     BOOL                adjust_h=TRUE;
  929.     BOOL                adjust_w=TRUE;
  930.     struct  DrawInfo    *mydr;
  931.  
  932.     if(FindTagItem(IA_Height,((struct opSet *)msg)->ops_AttrList))adjust_h=FALSE;
  933.     if(FindTagItem(IA_Width, ((struct opSet *)msg)->ops_AttrList))adjust_w=FALSE;
  934.  
  935.     what=   GetTagData(SYSIA_Which, 0x0, ((struct opSet *)msg)->ops_AttrList);
  936.     mydr=   (struct DrawInfo *)GetTagData(SYSIA_DrawInfo,0x0,((struct opSet *)msg)->ops_AttrList);
  937.     if(object=(Object *)DoSuperMethodA(cl,object,msg))
  938.     {
  939.         BOOPSI_InitData
  940.  
  941.         switch(what)
  942.         {
  943.         case    SIZEIMAGE:
  944.             SetAttrs(object,IA_Width,b_width,IA_Height,b_height,TAG_DONE);
  945.             break;
  946.         case    LEFTIMAGE:
  947.         case    RIGHTIMAGE:
  948.         case    UPIMAGE:
  949.         case    DOWNIMAGE:
  950.             if(adjust_h)
  951.             {
  952.                 SetAttrs(object,IA_Height,b_height,TAG_DONE);
  953.             }
  954.             if(adjust_w)
  955.             {
  956.                 SetAttrs(object,IA_Width,b_width,TAG_DONE);
  957.             }
  958.             break;
  959.         case    CLOSEIMAGE:
  960.         case    ZOOMIMAGE:
  961.         case    DEPTHIMAGE:
  962.             {
  963.                 LONG    tmp;
  964.                 GetAttr(IA_Height,object,&tmp);
  965.                 if(tmp)  SetAttrs(object,IA_Height,tmp+(b_top-2),TAG_DONE);
  966.             }
  967.             break;
  968.         }
  969.         data->what=what;
  970.     }
  971.     return(object);
  972.     }
  973.     BOOPSI_Method_End
  974.  
  975.     BOOPSI_Method(IM_DRAW)
  976.     {
  977.     struct  impDraw     *imsg;
  978.  
  979.     BOOPSI_InitData;
  980.  
  981.     if((imsg=(struct impDraw *)msg)->imp_DrInfo)
  982.     {
  983.         if(imsg->imp_DrInfo->dri_Version==NEWDRIVERSION)
  984.         {
  985.         switch (data->what)
  986.         {
  987.             case    CHECKIMAGE:
  988.             case    MXIMAGE:
  989.                 {
  990.                 UWORD   minx,miny,maxx,maxy;
  991.                 struct  RastPort    *rp=imsg->imp_RPort;
  992.                 UWORD   *pens=imsg->imp_DrInfo->dri_Pens;
  993.                 minx=imsg->imp_Offset.X+((struct Image *)object)->LeftEdge;
  994.                 miny=imsg->imp_Offset.Y+((struct Image *)object)->TopEdge;
  995.                 maxx=minx+((struct Image *)object)->Width -1;
  996.                 maxy=miny+((struct Image *)object)->Height-1;
  997.                 if(XStyle)
  998.                 {
  999.                     if(imsg->imp_State==IDS_SELECTED) draw_frame (rp,minx,miny,maxx,maxy,pens[HALFSHADOWPEN],pens[SHINEPEN],pens[HALFSHADOWPEN],pens[SHINEPEN],pens[HALFSHINEPEN],TRUE);
  1000.                     else                              draw_frame (rp,minx,miny,maxx,maxy,pens[SHINEPEN],pens[HALFSHADOWPEN],pens[SHINEPEN],pens[HALFSHADOWPEN],pens[HALFSHINEPEN],TRUE);
  1001.                 }
  1002.                 else
  1003.                 {
  1004.                     if(imsg->imp_State==IDS_SELECTED) draw_frame (rp,minx,miny,maxx,maxy,pens[SHADOWPEN],pens[SHADOWPEN],pens[HALFSHADOWPEN],pens[SHINEPEN],pens[HALFSHINEPEN],TRUE);
  1005.                     else                              draw_frame (rp,minx,miny,maxx,maxy,pens[SHADOWPEN],pens[SHADOWPEN],pens[SHINEPEN],pens[HALFSHADOWPEN],pens[HALFSHINEPEN],TRUE);
  1006.                 }
  1007.                 if(imsg->imp_State==IDS_SELECTED)
  1008.                 {
  1009.                     SetAPen(rp,pens[FILLPEN]);
  1010.                     if(((maxx-minx)>5)&&((maxy-miny)>5)) RectFill(rp,minx+3,miny+3,maxx-3,maxy-3);
  1011.                 }
  1012.                 }
  1013.                 return(TRUE);
  1014.                 break;
  1015.             default:
  1016.                 if(sysihackstyle)
  1017.                 {
  1018.                 return(DrawSysiHack(data,imsg,object,cl,msg));
  1019.                 }
  1020.                 else
  1021.                 {
  1022.                 return(DrawUrou    (data,imsg,object,cl,msg));
  1023.                 }
  1024.                 break;
  1025.         }
  1026.         }
  1027.     }
  1028.     BOOPSI_Method_SuperReturn;
  1029.     }
  1030.     BOOPSI_Method_End
  1031.  
  1032.     BOOPSI_Method_SuperDefault
  1033. BOOPSI_End
  1034.  
  1035. /************************************************************************/
  1036. /* Patched functions                                                    */
  1037. /************************************************************************/
  1038.  
  1039. ULONG  oldOTLRoutine;
  1040. extern newOTLRoutine();
  1041. ULONG  oldOSRoutine;
  1042. extern newOSRoutine();
  1043. ULONG  oldCSRoutine;
  1044. extern newCSRoutine();
  1045. ULONG  oldOWTLRoutine;
  1046. extern newOWTLRoutine();
  1047. ULONG  oldOWRoutine;
  1048. extern newOWRoutine();
  1049.  
  1050. fail()
  1051. {
  1052.     PutStr("***uRøURAçK sUCKS! Please run it before any screen was opened or IPrefs was started!\n\nPlease reboot your machine now, the system could be unstable!");
  1053.     exit(0);
  1054. }
  1055.  
  1056. enum{SCRFIL,WIN_TOP,WIN_BOT,WIN_LEF,WIN_RIG,FINBOT,FINRIG,PATFRAME,PATSYSI,ONLYWIN,TRYMWB,SYSISTYLE,XWIN,ARG_COUNT};
  1057. #define ARGTEMPLATE "SCREENFILE/M,WINDOW_TOP/K/N,WINDOW_BOTTOM/K/N,WINDOW_LEFT/K/N,WINDOW_RIGHT/K/N,FINE_BOTTOM/K/N,FINE_RIGHT/K/N,NOFRAMEPATCH/S,NOSYSIPATCH/S,ONLYWINDOWIMAGES/S,TRYMAGICWB/S,SYSIHACKSTYLE/S,XWINSTYLE/S"
  1058.  
  1059. enum{SCRNAME,SCRPEN1,SCRPEN2,SCRPEN3,SCRPEN4,ALLMWB,SCRARG_COUNT};
  1060. #define SCRARGTMPL "SCREEN,PEN1/N,PEN2/N,PEN3/N,PEN4/N,ALLOCATEMWB/S"
  1061.  
  1062. getscreenlist(char *filename)
  1063. {
  1064.     BPTR    file;
  1065.     STRPTR  *ArgArray;
  1066.     char    *line,*name;
  1067.  
  1068.     if(line=(char *)AllocVecPooled(swim_in_my_pool,256L))
  1069.     {
  1070.     if(file=(BPTR)Open(filename,MODE_OLDFILE))
  1071.     {
  1072.         int i=0;
  1073.         while(FGets(file,line,255))
  1074.         {
  1075.         i++;
  1076.         if(penlist[i]=(struct NewPenStruct *)AllocVecPooled(swim_in_my_pool,sizeof(struct NewPenStruct)))
  1077.         {
  1078.             if(ArgArray = (STRPTR *)AllocVecPooled(swim_in_my_pool,(sizeof(STRPTR) * (SCRARG_COUNT)) + 16L))
  1079.             {
  1080.             struct RDArgs *rd;
  1081.             if(rd=(struct RDArgs *)AllocDosObject(DOS_RDARGS,TAG_DONE))
  1082.             {
  1083.                 rd->RDA_Source.CS_Buffer=line;
  1084.                 rd->RDA_Source.CS_Length=strlen(line);
  1085.                 rd->RDA_Source.CS_CurChr=0L;
  1086.  
  1087.                 if(ReadArgs(SCRARGTMPL,(LONG *)ArgArray,rd))
  1088.                 {
  1089.                 if(ArgArray[SCRNAME])
  1090.                 {
  1091.                     if(name = (char *)((LONG *)ArgArray[SCRNAME]))
  1092.                     {
  1093.                     if(namelist[i]=(char *)AllocVecPooled(swim_in_my_pool,strlen(name)+4L))
  1094.                     {
  1095.                         strcpy(namelist[i],name);
  1096.                     }
  1097.                     }
  1098.                 }
  1099.                 if(ArgArray[SCRPEN1])
  1100.                 {
  1101.                     penlist[i]->halfdark   = (UWORD)(*(LONG *)ArgArray[SCRPEN1])&0xFFFF;
  1102.                 }
  1103.                 if(ArgArray[SCRPEN2])
  1104.                 {
  1105.                     penlist[i]->halfshine  = (UWORD)(*(LONG *)ArgArray[SCRPEN2])&0xFFFF;
  1106.                 }
  1107.                 if(ArgArray[SCRPEN3])
  1108.                 {
  1109.                     penlist[i]->darkpaint  = (UWORD)(*(LONG *)ArgArray[SCRPEN3])&0xFFFF;
  1110.                 }
  1111.                 if(ArgArray[SCRPEN4])
  1112.                 {
  1113.                     penlist[i]->shinepaint = (UWORD)(*(LONG *)ArgArray[SCRPEN4])&0xFFFF;
  1114.                 }
  1115.                 if(ArgArray[ALLMWB])
  1116.                 {
  1117.                     exttrymwb[i]=TRUE;
  1118.                 }
  1119.                 FreeArgs(rd);
  1120.                 }
  1121.                 FreeDosObject(rd);
  1122.             }
  1123.             FreeVecPooled(ArgArray);
  1124.             }
  1125.         }
  1126.         }
  1127.         Close(file);
  1128.     }
  1129.     else PutStr("***UROUHACK: Could not open screenlist file!");
  1130.     FreeVecPooled(line);
  1131.     }
  1132. }
  1133.  
  1134. getconfig()
  1135. {
  1136.     STRPTR  *ArgArray;
  1137.     if(ArgArray = (STRPTR *)AllocVecPooled(swim_in_my_pool,(sizeof(STRPTR) * (ARG_COUNT)) + 16L))
  1138.     {
  1139.     struct RDArgs *rd;
  1140.     if(rd=(struct RDArgs *)AllocDosObject(DOS_RDARGS,TAG_DONE))
  1141.     {
  1142.         if(ReadArgs(ARGTEMPLATE,(LONG *)ArgArray,rd))
  1143.         {
  1144.         if(ArgArray[SCRFIL])
  1145.         {
  1146.             if((char *)(*(LONG *)ArgArray[SCRFIL]))
  1147.             {
  1148.             getscreenlist((char *)(*(LONG *)ArgArray[SCRFIL]));
  1149.             }
  1150.         }
  1151.         if(ArgArray[WIN_TOP])
  1152.         {
  1153.             b_top = (BYTE)(*(LONG *)ArgArray[WIN_TOP])&0xFF;
  1154.         }
  1155.         if(ArgArray[WIN_BOT])
  1156.         {
  1157.             b_bottom = (BYTE)(*(LONG *)ArgArray[WIN_BOT])&0xFF;
  1158.         }
  1159.         if(ArgArray[WIN_LEF])
  1160.         {
  1161.             b_left = (BYTE)(*(LONG *)ArgArray[WIN_LEF])&0xFF;
  1162.         }
  1163.         if(ArgArray[WIN_RIG])
  1164.         {
  1165.             b_right = (BYTE)(*(LONG *)ArgArray[WIN_RIG])&0xFF;
  1166.         }
  1167.         if(ArgArray[FINBOT])
  1168.         {
  1169.             b_height = (*(LONG *)ArgArray[FINBOT])&0xFF;
  1170.         }
  1171.         if(ArgArray[FINRIG])
  1172.         {
  1173.             b_width = (*(LONG *)ArgArray[FINBOT])&0xFF;
  1174.         }
  1175.         if(ArgArray[PATFRAME])
  1176.         {
  1177.             pframes=FALSE;
  1178.         }
  1179.         if(ArgArray[PATSYSI])
  1180.         {
  1181.             psysi=FALSE;
  1182.         }
  1183.         if(ArgArray[ONLYWIN])
  1184.         {
  1185.             pwin=FALSE;
  1186.         }
  1187.         if(ArgArray[TRYMWB])
  1188.         {
  1189.             trymwb=TRUE;
  1190.         }
  1191.         if(ArgArray[SYSISTYLE])
  1192.         {
  1193.             sysihackstyle=TRUE;
  1194.         }
  1195.         if(ArgArray[XWIN])
  1196.         {
  1197.             XStyle=TRUE;
  1198.         }
  1199.         FreeArgs(rd);
  1200.         }
  1201.         FreeDosObject(rd);
  1202.     }
  1203.     FreeVecPooled(ArgArray);
  1204.     }
  1205. }
  1206.  
  1207. void main(int argc, char *argv[])
  1208. {
  1209.     UWORD   pens[8];
  1210.     struct  TextAttr topaz_font = { "topaz.font", 8, 0, FPF_ROMFONT, };
  1211.     struct  DrawInfo mydrawinfo = { DRI_VERSION, 9, &pens[BACKGROUNDPEN], 0, 2, 1, 1, NULL, NULL, NULL, 0, 0, 0, 0, 0 };
  1212.     Class   *my_cl,*oldcl;
  1213.     Object  *g;
  1214.     if(swim_in_my_pool=(ULONG *)CreatePool(MEMF_CLEAR|MEMF_PUBLIC,8192L,4096L))
  1215.     {
  1216.     getconfig();
  1217.     if(pframes)
  1218.     {
  1219.         Forbid();
  1220.         oldOTLRoutine = SetFunction(IntuitionBase,(WORD)-612,newOTLRoutine);
  1221.         oldOSRoutine  = SetFunction(IntuitionBase,(WORD)-198,newOSRoutine);
  1222.         oldCSRoutine  = SetFunction(IntuitionBase,(WORD)-66 ,newCSRoutine);
  1223.         Permit();
  1224.         if( g=(Object *)NewObject(NULL,"frameiclass",IA_Width,10,IA_Height,10, TAG_END))
  1225.         {
  1226.         oldcl=OCLASS(g); DisposeObject(g);
  1227.         Forbid();
  1228.  
  1229.         oldcl->cl_ID="breizhclass";
  1230.  
  1231.         if(my_cl=initFRAMEClass())
  1232.         {
  1233.             AddClass(my_cl);
  1234.             Permit();
  1235.         }
  1236.         else fail();
  1237.         }
  1238.         else fail();
  1239.     }
  1240.     if(psysi)
  1241.     {
  1242.         mydrawinfo.dri_Font=(struct TextFont *)OpenFont(&topaz_font);
  1243.         Forbid();
  1244.         oldOWTLRoutine= SetFunction(IntuitionBase,(WORD)-606,newOWTLRoutine);
  1245.         oldOWRoutine  = SetFunction(IntuitionBase,(WORD)-204,newOWRoutine);
  1246.         Permit();
  1247.         if( g=(Object *)NewObject(NULL, "sysiclass", SYSIA_Which, RIGHTIMAGE, SYSIA_DrawInfo, &mydrawinfo, TAG_END))
  1248.         {
  1249.         oldcl=OCLASS(g); DisposeObject(g);
  1250.         Forbid();
  1251.  
  1252.         oldcl->cl_ID="urouclass";
  1253.  
  1254.         if(my_cl=initSYSIClass())
  1255.         {
  1256.             AddClass(my_cl);
  1257.             Permit();
  1258.         }
  1259.         else fail();
  1260.         }
  1261.         else fail();
  1262.         if( g=(Object *)NewObject(NULL,"buttongclass",GA_Width,10,GA_Height,10,TAG_END))
  1263.         {
  1264.         oldcl=OCLASS(g); DisposeObject(g);
  1265.         Forbid();
  1266.  
  1267.         oldcl->cl_ID="tinicclass";
  1268.  
  1269.         if(my_cl=initGADClass())
  1270.         {
  1271.             AddClass(my_cl);
  1272.             Permit();
  1273.         }
  1274.         else fail();
  1275.         }
  1276.         else fail();
  1277.     }
  1278.     if(Cli()) ((struct CommandLineInterface *)Cli())->cli_Module=0L; /* That wwas a good tip ;-)) */
  1279.     else      Wait(0L); /* for the security */
  1280.     }
  1281.     else PutStr("***UROUHACK: Could not create memory pool!");
  1282. }
  1283.  
  1284.